<?php
define('APP_ADMIN_VIEW', TEMPLATE_PATH . '/admin' . DIRECTORY_SEPARATOR);
define('APP_ADMIN_NAME', basename(dirname(__FILE__))); //自定义管理后台名称

/**
 * 子应用入口
 * @param  array
 * @return [type]
 */
function run_admin_app($uri = array()) {
	require_once APP_PATH . '/' . APP_ADMIN_NAME . '/helper/helper.php';
	if (isset($uri[2]) && !empty($uri[2])) {
		$module = $uri[2];
		$action = isset($uri[3]) ? trim($uri[3]) : '';
		$app_run = APP_PATH . '/' . APP_ADMIN_NAME . '/' . $module . '/run.php';
		if (file_exists($app_run)) {
			require_once $app_run;

			if (function_exists('run_' . $module . '_app')) {
				call_user_func('run_' . $module . '_app', $action);
			}
		} else {
			show_not_found();
		}

	} else {
		$app_run = APP_PATH . '/' . APP_ADMIN_NAME . '/home/run.php';
		if (file_exists($app_run)) {
			require_once $app_run;
			if (function_exists('run_home_app')) {
				call_user_func('run_home_app', '');
			}
		}
	}
}